package com.example.thirdhomework

import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.example.thirdhomework.databinding.ActivityThirdBinding

class ThirdActivity : AppCompatActivity() {

    private lateinit var binding: ActivityThirdBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityThirdBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val launcherPhoto = registerForActivityResult(ActivityResultContracts.TakePicturePreview()) {
            binding.imageView.setImageBitmap(it)
        }
        binding.button.setOnClickListener {
            launcherPhoto.launch(null)
        }
    }
}